package com.maisha.utils;


public class SuitConstant {

	 public interface IType {
        public int getValue();
	    public String getExpr();
    }
	 
	 /**
	* 根据类型 和值 获得 结果
	* @param value
	* @param types
	* @return
	 */
     public static String getType(int value,IType[] types) {
         for (IType type : types) {
             if (type.getValue() == value) {
                 return type.getExpr();
             }
         }
         return null;
     }
	
     public static int getType(String expr,IType[] types) {
         for (IType type : types) {
             if (type.getExpr().equals(expr.trim()))
                 return type.getValue();
         }
         return -1;
     }
	
	 /**
	  * 标识数据是否有效 
	  * @author zhutf
	  */
	 public enum isValid implements IType {
	    	VALID(1,"有效"),NOT_VALID(2,"无效");
	    	 private final int value;
	         private final String expr;

	         private isValid(int value, String expr) {
	             this.value = value;
	             this.expr = expr;
	         }
			
			public int getValue() {
				return value;
			}
			@Override
			public String getExpr() {
				return expr;
			}
	 }
	 
	 
}
